<template>
    <iframe class="iframe" :src="url"></iframe>
</template>
<script>
import axios from 'axios';
export default {
  data() {
    return {
      url: '',
      htmlSrc: '',
    };
  },
  created(){
    this.getWxContent();
  },
  methods: {
    getWxContent(){
      let realurl = 'http://cors-anywhere.herokuapp.com/' + this.$API.DEEP_PLOUGHING_PATH;
      axios.get(realurl).then(res=>{
        let html = res.data;
                    html = html.replace(/data-src/g, "src")
                        .replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/g, '')
                        .replace(/https/g, 'http');
                    // let html_src = 'data:text/html;charset=utf-8,' + html;
                    let html_src = html;
                    let iframe = document.getElementById('iFrame');
                    iframe.src = html_src;
                    var doc = iframe.contentDocument || iframe.document;
                    doc.write(html_src);
                    doc.getElementById("js_content").style.visibility = "visible";
      })
      
      //   const toast = this.$toast.loading("加载中...");
      // this.$http.post(this.$API.GET_WX_CONTENT, {url:this.$API.DEEP_PLOUGHING_PATH}).then((res) => {
      //   console.log('res',res);
      //   toast.clear();
      //   if (res.code == 1) {
      //     let data = res.data.replace(/data-src/g, 'src');
      //     this.htmlSrc = 'data:text/html;charset=utf-8,' + data; // 解析码解决乱码
      //   } else {
      //     this.$notify({ type: "warning", message: res.msg });
      //   }
      // });
      }
  }
};
</script>
  
<style lang="less">
.iframe {
  width: 100%;
  height: 100%;
}
</style>
  